import request from '@/utils/request'

// 查询竞赛地区列表
export function listRegion(query) {
  return request({
    url: '/race/region/list',
    method: 'get',
    params: query
  })
}

// 查询竞赛地区详细
export function getRegion(id) {
  return request({
    url: '/race/region/' + id,
    method: 'get'
  })
}

// 新增竞赛地区
export function addRegion(data) {
  return request({
    url: '/race/region',
    method: 'post',
    data: data
  })
}

// 修改竞赛地区
export function updateRegion(data) {
  return request({
    url: '/race/region',
    method: 'put',
    data: data
  })
}

// 删除竞赛地区
export function delRegion(ids) {
  return request({
    url: '/race/region/' + ids,
    method: 'delete'
  })
}

// 查询所有省份
export function getProvinces() {
  return request({
    url: '/race/region/provinces',
    method: 'get'
  })
}

// 根据省份查询所有市
export function getCities(province) {
  return request({
    url: '/race/region/cities',
    method: 'get',
    params: { province }
  })
}

// 根据省份和市查询所有县/区
export function getDistricts(province, city) {
  return request({
    url: '/race/region/districts',
    method: 'get',
    params: { province, city }
  })
}
